package com.frejoys.store.controller;

import com.frejoys.common.aop.Authority;
import com.frejoys.common.aop.Authorization;
import com.frejoys.common.constant.CommonConstant;
import com.frejoys.common.dto.store.StoreSaleListDto;
import com.frejoys.common.response.Result;
import com.frejoys.common.util.RequestUtil;
import com.frejoys.common.vo.store.StoreStatisticsDayVo;
import com.frejoys.common.vo.store.StoreStatisticsMonthVo;
import com.frejoys.common.vo.store.StoreStatisticsYearVo;
import com.frejoys.service.StoreStatisticsDayService;
import com.frejoys.service.StoreStatisticsMonthService;
import com.frejoys.service.StoreStatisticsYearService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "店铺销售统计", description = "店铺销售统计")
@RestController
@RequiredArgsConstructor
@RequestMapping(CommonConstant.routePrefixStore)
@Authorization(Authority.Private)
public class MallStoreStatisticController {

    private final StoreStatisticsYearService storeStatisticsYearService;

    private final StoreStatisticsMonthService storeStatisticsMonthService;

    private final StoreStatisticsDayService storeStatisticsDayService;


     @Operation(summary = "店铺销售年统计")
     @PostMapping("/storeStatistics/y")
     public Result<List<StoreStatisticsYearVo>> storeStatisticsY(@RequestBody @Validated StoreSaleListDto dto) {
         return Result.success(storeStatisticsYearService.getList(dto, RequestUtil.userId()));
     }


     @Operation(summary = "店铺销售月统计")
     @PostMapping("/storeStatistics/ym")
     public Result<List<StoreStatisticsMonthVo>> storeStatisticsYM(@RequestBody @Validated StoreSaleListDto dto) {
         return Result.success(storeStatisticsMonthService.getList(dto, RequestUtil.userId()));
     }


     @Operation(summary = "店铺销售日统计")
     @PostMapping("/storeStatistics/ymd")
     public Result<List<StoreStatisticsDayVo>> storeStatisticsYMD(@RequestBody @Validated StoreSaleListDto dto) {
         return Result.success(storeStatisticsDayService.getList(dto, RequestUtil.userId()));
     }


}
